/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import model.Pfad;

/**
 *
 * @author root
 */
public class RegelAlsText extends javax.swing.JFrame {
    
    private Pfad pfad;

    /**
     * Creates new form RegelAlsText
     */
    public RegelAlsText(Pfad pfad) {
        this.pfad = pfad;
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        initComponents();
        this.jLabel1.setText("<html>Regel: </br>" + getPfadText());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(153, 255, 153));
        jPanel1.setLayout(new java.awt.BorderLayout());

        jLabel1.setText(org.openide.util.NbBundle.getMessage(RegelAlsText.class, "RegelAlsText.jLabel1.text")); // NOI18N
        jPanel1.add(jLabel1, java.awt.BorderLayout.CENTER);

        jButton1.setText(org.openide.util.NbBundle.getMessage(RegelAlsText.class, "RegelAlsText.jButton1.text")); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1, java.awt.BorderLayout.PAGE_END);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables


private String getPfadText() {
        String text="";
        for (int i=0; i < pfad.getKnotenListe().size(); i++) {
            if (i==0) {
                text = "Wenn " + pfad.getKnotenListe().get(i).getLabel() + " = ";
                text = text + pfad.getKantenListe().get(i).getLabel() + "<br/>";
            } else if (i==(pfad.getKnotenListe().size()-1)) {
                text = text + ", dann " + pfad.getKnotenListe().get(i).getLabel() + "</html>";
            } else {
                text = text + "und " + pfad.getKnotenListe().get(i).getLabel() + " = ";
                text = text + pfad.getKantenListe().get(i).getLabel() + "<br/>";
            }
        }
        return text;
    }
}
